import { Repository } from "typeorm";
import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";

import { OrderStock, OrderStockGateway, CommonStock, CommonStockGateway } from "qqlx-core";
import { OrderStockSchema, CommonStockSchema } from "qqlx-cdk";

import { PgDaoBigId } from "../../lib/dao.pg.id-big";

@Injectable()
export class OrderStockDao extends PgDaoBigId<OrderStock> {
  constructor(
    @InjectRepository(OrderStockSchema)
    readonly repo: Repository<OrderStock>,
  ) {
    super({
      repository: repo,
      relations_name: OrderStockGateway.relations,
    });
  }
}

@Injectable()
export class CommonStockDao extends PgDaoBigId<CommonStock> {
  constructor(
    @InjectRepository(CommonStockSchema)
    readonly repo: Repository<CommonStock>,
  ) {
    super({
      repository: repo,
      relations_name: CommonStockGateway.relations,
    });
  }
}
